/**
 * 查ip归属
 * 
 */

const axios = require('axios');

if(process.argv.length<3 ){

    console.error('请输入一个ip作为参数，如36.155.10.31');

    process.exit();

}


let url = `https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=${process.argv[2]}&co=&resource_id=6006&t=1557717786112&ie=utf8&oe=utf8&cb=op_aladdin_callback&format=json&tn=baidu&cb=cbf&_=1557717729984`;




axios.get(url).then(res=>{

	//console.log(res.data);

	let str = res.data;


	let json = str.replace(/^\/\*\*\/cbf\(/,'').replace(/\);$/,'');


	console.log(JSON.parse(json));
	//console.log(res.data.body);
});